package com.blue.bluecode;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.ToggleButton;

import com.blue.bluecode.helper.ToastHelper;


public class ToggleButtonActivity extends Activity {

    private ToggleButton tbToggleButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toggle_button);
        getActionBar().setDisplayHomeAsUpEnabled(true);


        tbToggleButton = (ToggleButton) findViewById(R.id.tbToggleButton);
        tbToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if(b){
                    ToastHelper.showShort(ToggleButtonActivity.this, "状态为"+tbToggleButton.getTextOn());
                }else{
                    ToastHelper.showShort(ToggleButtonActivity.this, "状态为"+tbToggleButton.getTextOff());
                }
            }
        });

    }
}
